/**
 * Estilos para la página de listado de carreras
 * Inspirado en guca.cl con diseño moderno y responsive
 */

/* ===========================================
   VARIABLES Y UTILIDADES
   =========================================== */
:root {
    --primary-color: #ff782d;
    --primary-dark: #e6651a;
    --secondary-color: #10b981;
    --secondary-dark: #059669;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --success-color: #10b981;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Reset y base */
.carreras-listing-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--gray-700);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* ===========================================
   HERO SECTION
   =========================================== */
.carreras-hero {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 4rem 0 3rem;
    position: relative;
    overflow: hidden;
}

.carreras-hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grid" width="10" height="10" patternUnits="userSpaceOnUse"><path d="M 10 0 L 0 0 0 10" fill="none" stroke="rgba(255,255,255,0.1)" stroke-width="1"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
    opacity: 0.3;
}

.hero-content {
    text-align: center;
    position: relative;
    z-index: 2;
}

.hero-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.hero-title i {
    color: var(--warning-color);
    font-size: 2.2rem;
}

.hero-subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
    margin-bottom: 2rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin-top: 2rem;
}

.stat-item {
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--warning-color);
}

.stat-label {
    display: block;
    font-size: 0.9rem;
    opacity: 0.8;
    margin-top: 0.25rem;
}

/* ===========================================
   FILTROS
   =========================================== */
.carreras-filters {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 1.5rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.filters-container {
    background: var(--gray-50);
    border-radius: var(--border-radius);
    padding: 1.5rem;
}

.filters-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    align-items: end;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-label {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-label i {
    color: var(--gray-400);
    font-size: 0.8rem;
}

.filter-select,
.filter-input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--gray-200);
    border-radius: var(--border-radius-sm);
    font-size: 0.9rem;
    background: white;
    transition: all 0.2s ease;
}

.filter-select:focus,
.filter-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ===========================================
   RESULTADOS
   =========================================== */
.carreras-results {
    padding: 2rem 0 4rem;
    background: var(--gray-50);
    min-height: 50vh;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--gray-200);
}

.results-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--gray-800);
    margin: 0;
}

#results-count {
    color: var(--primary-color);
    font-weight: 700;
}

.view-controls {
    display: flex;
    gap: 0.5rem;
}

.view-btn {
    background: white;
    border: 2px solid var(--gray-200);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--gray-600);
}

.view-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.view-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* ===========================================
   GRID DE CARRERAS
   =========================================== */
.carreras-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.race-card {
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    border: 1px solid var(--gray-200);
}

.race-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

/* ===========================================
   IMAGEN DE CARRERA
   =========================================== */
.race-image {
    position: relative;
    height: 200px;
    overflow: hidden;
}

.race-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.race-card:hover .race-image img {
    transform: scale(1.05);
}

.race-image-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--gray-200) 0%, var(--gray-300) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-400);
    font-size: 3rem;
}

.race-type-badge {
    position: absolute;
    top: 1rem;
    left: 1rem;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.race-type-badge.rutas {
    background: #ff782d;
    color: white;
}

.race-type-badge.infantiles {
    background: var(--warning-color);
    color: white;
}

.race-type-badge.medio_rally {
    background: var(--secondary-color);
    color: white;
}

.race-type-badge.rally_completo {
    background: var(--danger-color);
    color: white;
}

.availability-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.availability-badge.full {
    background: var(--danger-color);
    color: white;
}

.availability-badge.almost-full {
    background: var(--warning-color);
    color: white;
}

/* ===========================================
   CONTENIDO DE CARRERA
   =========================================== */
.race-content {
    padding: 1.5rem;
}

.race-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.race-name {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-800);
    margin: 0;
    line-height: 1.3;
    flex: 1;
    margin-right: 1rem;
}

.race-price {
    text-align: right;
    flex-shrink: 0;
}

.price-amount {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
}

.race-info {
    margin-bottom: 1rem;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--gray-600);
}

.info-item i {
    color: var(--gray-400);
    width: 1rem;
    text-align: center;
}

.race-description {
    color: var(--gray-600);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 1.5rem;
}

.race-footer {
    margin-top: auto;
}

/* ===========================================
   BOTONES
   =========================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(.disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}

.btn-secondary:hover {
    background: var(--gray-200);
    border-color: var(--gray-400);
}

.btn.disabled {
    background: var(--gray-300);
    color: var(--gray-500);
    cursor: not-allowed;
    opacity: 0.6;
}

/* ===========================================
   MENSAJE SIN CARRERAS
   =========================================== */
.no-races-message {
    text-align: center;
    padding: 4rem 2rem;
    grid-column: 1 / -1;
}

.no-races-icon {
    font-size: 4rem;
    color: var(--gray-300);
    margin-bottom: 1rem;
}

.no-races-message h3 {
    font-size: 1.5rem;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.no-races-message p {
    color: var(--gray-500);
    margin-bottom: 2rem;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

/* ===========================================
   RESPONSIVE - MEJORADO PARA MÓVILES
   =========================================== */

/* Tablets y pantallas medianas */
@media (max-width: 1024px) {
    .carreras-grid {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)) !important;
        gap: 1.25rem !important;
    }
    
    .race-card {
        max-width: none !important;
    }
}

/* Móviles grandes */
@media (max-width: 768px) {
    .container {
        padding: 0 15px !important;
        max-width: 100% !important;
    }
    
    .carreras-hero {
        padding: 2rem 0 1.5rem !important;
    }
    
    .hero-title {
        font-size: 1.8rem !important;
        flex-direction: column !important;
        gap: 0.5rem !important;
        text-align: center !important;
    }
    
    .hero-subtitle {
        font-size: 1rem !important;
        text-align: center !important;
    }
    
    .hero-stats {
        flex-direction: column !important;
        gap: 1rem !important;
    }
    
    .filters-container {
        padding: 1rem !important;
        margin: 0 !important;
    }
    
    .filters-row {
        grid-template-columns: 1fr !important;
        gap: 0.8rem !important;
    }
    
    .filter-select,
    .filter-input,
    .btn {
        padding: 12px !important;
        font-size: 16px !important; /* Evita zoom en iOS */
        border-radius: 8px !important;
        min-height: 44px !important; /* Tamaño mínimo para touch */
    }
    
    .results-header {
        flex-direction: column !important;
        gap: 1rem !important;
        align-items: stretch !important;
        text-align: center !important;
    }
    
    .view-controls {
        justify-content: center !important;
    }
    
    .carreras-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
        padding: 0 !important;
    }
    
    .race-card {
        margin: 0 auto !important;
        max-width: 100% !important;
        width: 100% !important;
    }
    
    .race-image {
        height: 180px !important;
    }
    
    .race-content {
        padding: 1rem !important;
    }
    
    .race-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.5rem !important;
    }
    
    .race-name {
        font-size: 1.1rem !important;
        line-height: 1.3 !important;
        margin-right: 0 !important;
    }
    
    .race-price {
        text-align: left !important;
        width: 100% !important;
    }
    
    .price-amount {
        font-size: 1.2rem !important;
    }
    
    .race-info {
        margin-bottom: 0.8rem !important;
    }
    
    .info-item {
        font-size: 0.9rem !important;
        margin-bottom: 0.4rem !important;
    }
    
    .race-description {
        font-size: 0.85rem !important;
        margin-bottom: 1rem !important;
    }
    
    .btn {
        width: 100% !important;
        padding: 15px 20px !important;
        font-size: 16px !important;
        font-weight: 600 !important;
        min-height: 50px !important;
        touch-action: manipulation !important;
    }
}

/* Móviles pequeños */
@media (max-width: 480px) {
    .container {
        padding: 0 10px !important;
    }
    
    .carreras-hero {
        padding: 1.5rem 0 1rem !important;
    }
    
    .hero-title {
        font-size: 1.5rem !important;
    }
    
    .hero-subtitle {
        font-size: 0.9rem !important;
    }
    
    .filters-container {
        padding: 0.8rem !important;
        border-radius: 8px !important;
    }
    
    .race-content {
        padding: 0.8rem !important;
    }
    
    .race-name {
        font-size: 1rem !important;
    }
    
    .price-amount {
        font-size: 1.1rem !important;
    }
    
    .info-item {
        font-size: 0.85rem !important;
    }
    
    .race-description {
        font-size: 0.8rem !important;
    }
    
    .btn {
        padding: 12px 16px !important;
        font-size: 15px !important;
        min-height: 48px !important;
    }
}

/* Mejorar touch targets para móvil */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .filter-select,
    .filter-input,
    .view-btn {
        min-height: 44px !important; /* Tamaño mínimo recomendado por Apple */
        touch-action: manipulation !important;
    }
    
    .race-card {
        touch-action: manipulation !important;
    }
    
    .race-name a {
        display: block !important;
        padding: 5px 0 !important;
        min-height: 44px !important;
        display: flex !important;
        align-items: center !important;
    }
}

/* Optimizaciones adicionales para performance en móvil */
@media (max-width: 768px) {
    .race-card:hover {
        transform: none !important; /* Quitar efectos hover en móvil */
    }
    
    .race-card:hover .race-image img {
        transform: none !important;
    }
    
    .btn-primary:hover {
        transform: none !important;
    }
}

/* Asegurar que el grid sea totalmente responsive */
.carreras-grid {
    width: 100% !important;
    box-sizing: border-box !important;
}

.race-card {
    box-sizing: border-box !important;
}

/* Evitar overflow horizontal */
.carreras-listing-container {
    overflow-x: hidden !important;
    width: 100% !important;
}

.carreras-filters,
.carreras-results {
    overflow-x: hidden !important;
}

/* ===========================================
   ANIMACIONES
   =========================================== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.race-card {
    animation: fadeInUp 0.5s ease-out;
}

.race-card:nth-child(1) { animation-delay: 0.1s; }
.race-card:nth-child(2) { animation-delay: 0.2s; }
.race-card:nth-child(3) { animation-delay: 0.3s; }
.race-card:nth-child(4) { animation-delay: 0.4s; }
.race-card:nth-child(5) { animation-delay: 0.5s; }
.race-card:nth-child(6) { animation-delay: 0.6s; }

/* ===========================================
   STATES DE LOADING
   =========================================== */
.loading-skeleton {
    background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}